package com.yuma.springshiroredisthymeleaf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    // 需要我们自己把国家化支持添加到spring mvc中
    @Bean
    public LocaleResolver localeResolver(){
        return new I18nResolver();
    }

    // 添加视图映射 Controller->View
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/index").setViewName("index");
        registry.addViewController("/login").setViewName("login");
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/logout").setViewName("logout");
        registry.addViewController("/unauthorized").setViewName("unauthorized");
    }
}
